<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Stars Background</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
    integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA=="
    crossorigin="anonymous" referrerpolicy="no-referrer" />
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <section class="sec"></section>
</body>
<script>
  for (let i = 1; i <= 75; i++) {
    let starts = document.createElement('div')
    starts.classList.add('star')

    let size = Math.random() * 20
    starts.style.fontSize = 10 + size + 'px'
    starts.style.left = Math.random() * + innerWidth + 'px'
    starts.style.top = Math.random() * + innerHeight + 'px'
    starts.style.filter = `hue-rotate(${i * 5}deg)`

    document.querySelector('.sec').appendChild(starts)
  }

  function animateStars() {
    let AllStars = document.querySelectorAll('.star')
    let num = Math.floor(Math.random() * AllStars.length)
    AllStars[num].classList.toggle('animate')
  }

  setInterval(animateStars, 50);
</script>

</html>